<?php
class MeetingModel extends Model{

//--------------------------------------insert-------------------------------------------------------------
	public function add_meeting($data)
	{

		$data['meeting_startTime'] = strtotime($data['meeting_date'].' '.$data['meeting_startTime']);
		$data['meeting_endTime']   = strtotime($data['meeting_date'].' '.$data['meeting_endTime']);
		$data['time_insert']	   = time();
		$data['meeting_date']	   = date('Y-m-d',$data['meeting_startTime']);
		$data['meeting_sponsorsId']= 1;

		$data['meeting_local_type']= 1;
		//$data['meeting_local']   = $data['meeting_local'];
		//add meeting
		$rs = M('meeting','','DB_MEETING')->add($data);

		if($data['meeting_join_type'] != 1){
			$this->add_meeting_join($rs,$data['meeting_join']);
			$this->add_meeting_join_secret($rs,$data['meeting_join_secret']);
		}
		return $rs;
	}

	public function add_meeting_join($meeting_id,$meeting_join)
	{
		$meeting_join = explode(',',$meeting_join);
		foreach($meeting_join as $val){
			$newdata['meeting_id'] =$meeting_id;
			$newdata['audience_id']=$val;
			$newdata['join_state'] =0;
			M('meeting_join','','DB_MEETING')->add($newdata);
		}
	}
	public function add_meeting_secret($meeting_id,$meeting_join_secret)
	{
		$meeting_join_secret = explode(',',$meeting_join_secret);
		foreach($meeting_join_secret as $val){
			$newdata['meeting_id'] =$meeting_id;
			$newdata['audience_id']=$val;
			$newdata['join_state'] =0;
			$newdata['is_secret']  =1;
			M('meeting_join','','DB_MEETING')->add($newdata);
		}

	}
//--------------------------------------update-------------------------------------------------------------
//--------------------------------------delete-------------------------------------------------------------
//--------------------------------------select-------------------------------------------------------------
	public function get_meeting_categorys()
	{
		return M('meeting_category','','DB_MEETING')->where('time_insert>time_delete')->select();
	}



	private $meeting_details_cows="a.`meeting_id`,a.`meeting_title`,a.`meeting_sponsorsId`,b.audience_name as `meeting_sponsorsName`,b.audience_portrait,a.`meeting_description`,a.`meeting_startTime`,a.`meeting_endTime`,a.`meeting_local`,a.`time_insert`,a.`meeting_state`,a.`meeting_room_id`,c.room_name,d.floor_name,e.building_name,f.local_name";
	private $meeting_join_cows="b.`audience_id`,b.`audience_name`,a.`join_state`,b.`audience_portrait`,a.`join_content`";
	private $meeting_id="a.`meeting_id`";
	private $meeting_list_cows="a.`meeting_id`, a.`meeting_title`, a.`meeting_sponsorsId`, a.`meeting_description`, a.`meeting_startTime`, a.`meeting_endTime`, a.`meeting_local`, a.`time_insert`,b.audience_name as meeting_sponsorsName,b.audience_portrait,a.`meeting_state`,room_name,floor_name,building_name,local_name";
	private $meeting_list_cows_uid="a.`meeting_id`, a.`meeting_title`, a.`meeting_sponsorsId`, a.`meeting_description`, a.`meeting_startTime`, a.`meeting_endTime`, a.`meeting_local`, a.`time_insert`,d.audience_name as meeting_sponsorsName,d.audience_portrait,a.`meeting_state`,room_name,floor_name,building_name,local_name";
	private $search_type=array(0=>'主题',1=>'发起人',3=>'date',4=>'month');
	//新添加
	private $meeting_list_cows_new = 'a.meeting_id,a.meeting_title,a.meeting_startTime,a.meeting_endTime,b.room_name,c.floor_name,d.building_name,e.local_name';

/**
  *查询会议列表
  *update author: zhanghao
  *update time  : 2014-11-17 10:58
  *use    this	: A('Meeting')->check_idle_meeting_room	
  ****************************************/
  public function get_meeting_list($data){
	  	$sql = 'select '.$this->meeting_list_cows_new.',a.meeting_type from meeting a';
		$sql.= ' join meeting_room b on a.meeting_room_id=b.room_id';
		$sql.= ' join meeting_roomfloor c on b.floor_id=c.floor_id';
		$sql.= ' join meeting_roombuilding d on c.building_id=d.building_id';
		$sql.= ' join meeting_roomlocal e on d.local_id=e.local_id';
		$sql1=$sql.' where a.meeting_sponsorsId='.$data['uid'];
		$sql2= $sql.' join meeting_join f on a.meeting_id = f.meeting_id';
		$sql2.= ' where audience_id='.$data['uid'];
		$sql=$sql1.' union '.$sql2;
		$rs=M('meeting','','DB_MEETING')->query($sql);
		
		foreach($rs as $val){
			$new_val['title']=$val['meeting_title'].'地点:'.$val['local_name'].$val['building_name'].$val['floor_name'].$val['room_name'];
			$new_val['start']=date('Y-m-d H:m',$val['meeting_startTime']);
			$new_val['end']=date('Y-m-d H:m',$val['meeting_endTime']);
			$new_val['allDay']=false;
			switch($val['meeting_type']){
				case 1:$new_val['className']='label label-success';break;
				case 2:$new_val['className']='label label-warning';break;
				default:$new_val['className']='label label-info';break;
			}
			if($val['meeting_type']==2)
				$new_val['className']='label label-warning';
			
			$newarr[]=$new_val;
		}
		
		return $newarr;
	}
//城市查询
	public function get_local(){
		$sql = 'select * from meeting_roomlocal';
		return M('meeting_roomlocal','','DB_MEETING')->query($sql);
	}
//楼座查询
	public function get_build(){
		$sql = 'select * from meeting_roombuilding';
		return M('meeting_roombuild','','DB_MEETING')->query($sql);
	}
//楼层查询
	public function get_floor(){
		$sql = 'select * from meeting_roomfloor';
		return M('meeting_roomfloor','','DB_MEETING')->query($sql);
	}
//会议室所在地
	public function add_local($data){
		return M("meeting_roomlocal",'','DB_MEETING')->add($data);	
	}
//楼座
	public function add_build($data){
		return M("meeting_roombuilding",'','DB_MEETING')->add($data);
	}
//楼层
	public function add_floor($data){
		return M("meeting_roomfloor",'','DB_MEETING')->add($data);
	}
//添加会议室
	public function add_room($data){
		return M('meeting_room',"","DB_MEETING")->add($data);
	}
//查找id
	public function get_id($where){
		return M('meeting_room','','DB_MEETING')->where("room_id=".$where)->field("local_id,building_id,floor_id")->find();
	}
//删除回忆室
	public function del_room($where){
		return M('Meeting_room','','DB_MEETING')->where('room_id='.$where)->delete();
	}
//会议室查询
	public function find_room($data){
		return M('Meeting_room','','DB_MEETING')->where('room_id='.$data)->find();
	}
//城市条件查询
	public function find_local($data){
		return M('Meeting_roomlocal','','DB_MEETING')->where('local_id='.$data)->find();
	}
//楼座条件查询
	public function find_building($data){
		return M('Meeting_roombuilding','','DB_MEETING')->where('building_id='.$data)->find();
	}
//楼层条件查询
	public function find_floor($data){
		return M('Meeting_roomfloor','','DB_MEETING')->where('floor_id='.$data)->find();
	}
//会议室修改
	public function save_room($data){
		return M('Meeting_room','','DB_MEETING')->where('room_id='.$data['room_id'])->save($data);
	}
/**
  *搜索会议
  *update author: zhanghao
  *update time  : 2014-11-19 11:22
  *use    this	: A('Meeting')->search_meeting
  ****************************************/	
	public function search_meeting($data){
		switch($data['searchType']){
			case 1:$cow='d.`audience_name`';break;
			case 2:$cow='a.`meeting_title`';break;
			//case 3:$cow='c.`type_name`';break;
			default:
				$cow='d.`audience_name`';break;
		}
		if($data['conditions']!=''){
			$where = '  and INSTR ('.$cow.',"'.$data['conditions'].'")';
		}else{
			$where='';	
		}
		if($data['searchType']==3){
			$startTime=strtotime($data['conditions'].' 00:00:00');
			$endTime  =strtotime($data['conditions'].' 23:59:59');
			$where=' and a.meeting_startTime>='.$startTime.' and a.meeting_endTime<='.$endTime;
		}else if($data['searchType']==4){
			$date=explode('-',$data['conditions']);
			$startTime = strtotime($date[0].'-'.$date[1].'-'.'01 00:00:00');
			if($date[1]==12){
				$date[0]=(int)$date[0]+1;
				$date[1]='01';
			}else{
				$date[1]=(int)$date[1]+1;
			}
			$endTime = strtotime($date[0].'-'.$date[1].'-'.'01 00:00:00');
			$where=' and a.meeting_startTime>='.$startTime.' and a.meeting_endTime<'.$endTime;
		}
		
		if($data["uid"]!=''){
			$sql = "select ".$this->meeting_list_cows_uid.",c.join_state from meeting_join c";
			$sql.= " join meeting a on a.meeting_id=c.meeting_id";
			$sql.= " join audience b on c.audience_id=b.audience_id";
			$sql.= " join audience d on a.meeting_sponsorsId=d.audience_id";
			$sql.= ' join meeting_room f on a.meeting_room_id=f.room_id';
			$sql.= ' join meeting_roomfloor g on f.floor_id=g.floor_id';
			$sql.= ' join meeting_roombuilding h on g.building_id=h.building_id';
			$sql.= ' join meeting_roomlocal i on h.local_id=i.local_id';
			$sql.= " where c.audience_id=".$data['uid'].$where;
			$sql.= " order by a.`meeting_startTime` desc";
			$sql.= " limit ".(($data['page']-1)*$_REQUEST['count']).",".$data['count'];
		}else{
			$sql = "select ".$this->meeting_list_cows." from meeting as a";
			$sql.= " join audience as b on a.meeting_sponsorsId=b.audience_id";
			$sql.= ' join meeting_room f on a.meeting_room_id=f.room_id';
			$sql.= ' join meeting_roomfloor g on f.floor_id=g.floor_id';
			$sql.= ' join meeting_roombuilding h on g.building_id=h.building_id';
			$sql.= ' join meeting_roomlocal i on h.local_id=i.local_id';
			$sql.= ' where 1=1'.$where;
			$sql.= " order by ".$this->meeting_id." desc";
			$sql.= " limit ".(($data['page']-1)*$_REQUEST['count']).",".$data['count'];	
		}
		$rs=M("meeting","",'DB_MEETING')->query($sql);
		return $rs;
	}
	
	//创建会议
	public function create_meeting($data){
		$data['meeting_sponsorsId']=$data['uid'];
		$rs=M('meeting','','DB_MEETING')->add($data);
		if($rs){
			$arr=explode(',',$data['meeting_join']);
			foreach($arr as $val){
				$newdata['meeting_id']=$rs;
				$newdata['audience_id']=$val;
				$newdata['join_state']=0;
				M('meeting_join','','DB_MEETING')->add($newdata);
			}
			return $rs;
		}else{
			return false;	
		}
	}
	
	public function update_meeting_info($data){
		return M('meeting','','DB_MEETING')->where('meeting_id='.$data['meeting_id'])->save($data);	
	}
	
	//根据会议id获取会议相关信息
	public function get_meeting_by_id($id){
		$sql = "select ".$this->meeting_details_cows." from `meeting` as a";
		$sql.= " join audience as b on a.meeting_sponsorsId=b.audience_id";
		$sql.= ' join meeting_room c on a.meeting_room_id=c.room_id';
		$sql.= ' join meeting_roomfloor d on c.floor_id=d.floor_id';
		$sql.= ' join meeting_roombuilding e on d.building_id=e.building_id';
		$sql.= ' join meeting_roomlocal f on e.local_id=f.local_id';
		$sql.= " where a.meeting_id=".$id;
		$sql.= " limit 1";
		$rs  = M("meeting","",'DB_MEETING')->query($sql);
		if($rs)
			return $rs[0];
		else
			return false;
	}
	//查询会议的参会人
	public function get_meeting_join($id){
		$psql = "select ".$this->meeting_join_cows." from `meeting_join` as a";
		$psql.= " join audience as b on a.audience_id=b.audience_id";
		$psql.= " join meeting c on a.meeting_id=c.meeting_id";
		$psql.= " where a.meeting_id=".$id;
		$psql.= " and c.meeting_sponsorsId!=a.audience_id";
		$rs1  = M("meeting_join","",'DB_MEETING')->query($psql);
		return $rs1;
	}
	public function get_audience_by_meeting_id($id){
		return M('meeting_join','','DB_MEETING')->field('audience_id')->where('id=d%',$id)->select();
	}

	//获取会议信息
	public function check_idle_meeting_room_by_uid($data){
		//1.通过uid获取当前用户的部门信息
		$department	 = D('Department')->get_department_by_uid($data['uid']);
		$re['local_id']=$department['local_id'];
		$re['building_id']=$department['building_id'];
		$re['floor_id']=$department['floor_id'];
		//查询相关楼层信息
		$re['locals'] = $this->get_meeting_room_local();
		$re['buildings'] = $this->get_meeting_room_building($re['local_id']);
		$re['floors'] = $this->get_meeting_room_floor($re['building_id']);
		//查询符合条件的meeting_room
		$sql ='select room_id,room_name from meeting_room';
		$sql.=' where floor_id='.$department['floor_id'];
		$rs=M('meeting_room','','DB_MEETING')->query($sql);
		foreach($rs as $val){
			$sql ='select schedule_id from meeting_room_schedule';
			$sql.=' where room_id='.$val['room_id'];
			$sql.=' and schedule_startTime>='.$data['meeting_startTime'];
			$sql.=' and schedule_endTime<='.$data['meeting_endTime'];
			$rs=M('meeting_roomSchedule','','DB_MEETING')->query($sql);
			if(!$rs)
				$new[]=$val;
		}
		$re['meeting_room']=$new;
		return $re;	
	}
	
/**
  *查询会议室
  *update author: zhanghao
  *update time  : 2014-11-12 15:40
  *use    this	: A('Meeting')->check_idle_meeting_room
  ****************************************/	
	public function check_idle_meeting_room($data){
		$data['meeting_date']	= $data['meeting_date']==NULL?date('Y-m-d'):$data['meeting_date'];
		//$data['count']			= $data['count']==NULL?10:$data['count'];
		//$data['page']			= $data['page']==NULL?1:$data['page'];
		
		$sql = 'select * from meeting_room as b';
		$sql.= ' join meeting_roomfloor c on b.floor_id=c.floor_id';
		$sql.= ' join meeting_roombuilding d on c.building_id=d.building_id';
		$sql.= ' join meeting_roomlocal e on d.local_id=e.local_id';
		if($data['floor_id']!='')
			$sql.= ' where b.floor_id='.$data['floor_id'];
		$rs	 = M('meeting_room','','DB_MEETING')->query($sql);
		if(!$rs)
			return false;
		
		foreach($rs as $val){
			$sql1 ='select * from meeting_roomschedule';
			$sql1.=' where room_id='.$val['room_id'].' and schedule_date="'.$data['meeting_date'].'"';
			$sql1.=' limit 1';
			$schedule=M('meeting_roomschedule','','DB_MEETING')->query($sql1);
			if($schedule){
				if($data['maxstep']!=''){
					if($data['maxstep']>$schedule['schedule_maxstep'])
					continue;
				}
				$val['have_schedule']	=true;
				$val['schedule_states']	=$schedule;
			}else{
				$val['have_schedule']=false;
				$val['schedule_states']=false;
			}
			$arr[]=$val;
		}
		return $arr;	
	}
	
	//获取所有的地区信息
	public function get_meeting_room_local(){
		return M('meeting_room_local','','DB_MEETING')->query('SELECT * FROM  `meeting_room_local`');
	}
	//获取所有的楼座信息
	public function get_meeting_room_building($local){
		return M('meeting_room_building','','DB_MEETING')->query('SELECT * FROM  `meeting_room_building` where local_id='.$local); 	
	}
	//获取所有的楼层信息
	public function get_meeting_room_floor($building){
		return M('meeting_room_floor','','DB_MEETING')->query('SELECT * FROM  `meeting_room_floor` where building_id='.$building); 	
	}
	
	//取消会议
	public function cancel_meeting($id){
		$data['meeting_state']=0;
		//删除会议室预定
		M('meeting_roomSchedule','','DB_MEETING')->where('meeting_id='.$id)->delete();
		//取消会议
		$sql = 'update `meeting` set meeting_state=0 where meeting_id='.$id;
		return M('meeting','','DB_MEETING')->execute($sql);	
	}
	//修改参会状态
	public function update_join_state($data){
		return M('meeting_join','','DB_MEETING')->where('meeting_id='.$data['meeting_id'].' and audience_id='.$data['uid'])->save($data);
	}
/**
  *获取所有楼层
  *update author: zhanghao
  *update time  : 2014-11-10 09:52
  *use    this	: A('Meeting')->get_meeting_room_locals
  ****************************************/
  	public function get_all_floor(){
		return M('meeting_roomfloor','','DB_MEETING')->select();
	}
/**
  *获取所有地区
  *update author: zhanghao
  *update time  : 2014-11-10 09:52
  *use    this	: A('Meeting')->get_meeting_room_locals
  ****************************************/	
	public function get_all_local(){
		return M('meeting_roomlocal','','DB_MEETING')->select();
	}
/**
  *获取所有大楼
  *update author: zhanghao
  *update time  : 2014-11-10 09:52
  *use    this	: A('Meeting')->get_meeting_room_locals
  ****************************************/	
	public function get_all_building(){
		return M('meeting_roombuilding','','DB_MEETING')->select();
	}
/**
  *通过地区查询大楼
  *update author: zhanghao
  *update time  : 2014-12-1 11:41
  *use    this	: A('Meeting')->get_meeting_building
  ****************************************/	
  	public function get_building_list_by_local_id($local_id){
		return M('meeting_roombuilding','','DB_MEETING')->where('local_id='.$local_id)->select();	
	}
/**
  *通过地区查询大楼
  *update author: zhanghao
  *update time  : 2014-12-1 11:41
  *use    this	: A('Meeting')->get_meeting_floor
  ****************************************/	
  	public function get_floor_list_by_building_id($building_id){
		return M('meeting_roomfloor','','DB_MEETING')->where('building_id='.$building_id)->select();	
	}
/**
  *预定会议室
  *update author: zhanghao
  *update time  : 2014-11-28 11:28
  *use    this	: A('Meeting')->create_meeting
  ****************************************/	
	public function schedule_meeting_room($data){
		//init shedule time
		$data['room_id']= $data['meeting_room_id'];
		$start 			= $this->init_nums(date('H:i',$data['meeting_startTime']));
		$end	 		= $this->init_nums(date('H:i',$data['meeting_endTime']));
		
		//find room shedule info
		$sql ='select * from meeting_roomschedule';
		$sql.=' where schedule_date="'.$data['schedule_date'].'"';
		$sql.=' and room_id='.$data['meeting_room_id'];
		$sql.=' limit 1';
		$rs = M('meeting_roomschedule','','DB_MEETING')->query($sql);
		if($rs[0]){
			//select if it sheduled
			for($i=$start;$i<=$end;$i++){
				if($rs[0]['schedule_'.$i]==1)
					return false;
			}
			for($i=$start;$i<=$end;$i++){
				$data['schedule_'.$i]=1;
			}
			$rs=M('meeting_roomschedule','','DB_MEETING')->where('schedule_id='.$rs[0]['schedule_id'])->save($data);
			//update max time step
			$this->upt_max_step($rs[0]['schedule_id']);
			return $rs;
		}
		for($i=$start;$i<=$end;$i++){
			$data['schedule_'.$i]=1;
		}
		//update max time step
		$rs=M('meeting_roomschedule','','DB_MEETING')->add($data);
		$this->upt_max_step($rs);
		return $rs;
	}
/**
  *预定会议室
  *update author: zhanghao
  *update time  : 2014-11-28 11:28
  *use    this	: A('Meeting')->create_meeting
  ****************************************/	
	public function upt_max_step($id){
	   	$sql ='select * from meeting_roomschedule';
		$sql.=' where schedule_id='.$id;
		$sql.=' limit 1';
		$rs = M('meeting_roomschedule','','DB_MEETING')->query($sql);
		
		for($i=0;$i<=24;$i++){
			if($rs[0]['schedule_'.$i]==0)
				$data[]=$i;	
		}
		$j=-1;$y=0;
		foreach($data as $key=>$value){
			$j++;$i=$data[$key-1];
			if($i==($value-1)){
				$str[$y][]=$value;
			}else{
				$y++;
				$str[$y][]=$value;
			}
		}
		$max=0;
		foreach($str as $val){
			if(count($val)>$max)
				$max=count($val);
		}
		$data1['schedule_maxstep']=$max-1;
		return M('meeting_roomschedule','','DB_MEETING')->where('schedule_id='.$rs[0]['schedule_id'])->save($data1);
	}
/**
  *拼写相关的数字
  *update author: zhanghao
  *update time  : 2014-11-28 11:28
  *use    this	: $this->schedule_meeting_room
  ****************************************/	
	public function init_nums($time){
		switch($time){
			case '08:00':$num=0;break;
			case '08:30':$num=1;break;
			case '09:00':$num=2;break;
			case '09:30':$num=3;break;
			case '10:00':$num=4;break;
			case '10:30':$num=5;break;
			case '11:00':$num=6;break;
			case '11:30':$num=7;break;
			case '12:00':$num=8;break;
			case '12:30':$num=9;break;
			case '13:00':$num=10;break;
			case '13:30':$num=11;break;
			case '14:00':$num=12;break;
			case '14:30':$num=13;break;
			case '15:00':$num=14;break;
			case '15:30':$num=15;break;
			case '16:00':$num=16;break;
			case '16:30':$num=17;break;
			case '17:00':$num=18;break;
			case '17:30':$num=19;break;
			case '18:00':$num=20;break;
			case '18:30':$num=21;break;
			case '19:00':$num=22;break;
			case '19:30':$num=23;break;
			case '20:00':$num=24;break;
		}
		return $num;  
	}

    public function get_son_category($pid)
    {
        return M('meeting_category','','DB_MEETING')->where('category_pid='.$pid.' and time_insert>time_delete')->select();
    }
	
	public function pageing($righs,$where=''){
		$pageSize=10;
		$get_param='';
		$seach='';
		if($_GET['category_id']!='')
			$seach = 'and meeting_category='.$_GET['category_id'];
		$sql ='';
		$totalRow = '';
		$arr = explode(',',$where);
		if($righs == 2){
			foreach($arr as $val){
				$totalRow += (int)M('meeting','','DB_MEETING')->where('meeting_category='.$val.' '.$seach)->count();
				if($sql=='')	
					$sql.='select count(*) from meeting where meeting_category = '.$val;
			}
			$where = 'meeting_category in ('.$where.')';
		}else{
			$totalRow = M('meeting','','DB_MEETING')->where($where.' '.$seach)->count();
			$where = 1;
		}
		$order = 'meeting_id desc';
		if($order!=''){
			$get_param.="&order={$order}";
		}


		$totalPage= ceil($totalRow/$pageSize);
		$page=isset($_GET['page'])?$_GET['page']:1;
		$page=$page<1?$page=1:$page;
		$page=$page>$totalPage?$totalPage:$page;
		$first=($page-1)*$pageSize;
		$rs['data']=M("meeting",'','DB_MEETING')->where("{$where} {$seach}")->order("$order")->limit($first,$pageSize)->select();
	
		$now = 'meeting_list';
		
		if($_GET['category_id']!='')
			$now.= '?category_id='.$_GET['category_id'];
		else
			$now.= '?1=1';
		
		$now==''?'index':$now;
		$pageFor=__URL__."/".$now."&page=";
		
		

		
		if($_GET['category']){
			$get_param.='&category='.$_GET['category'];	
		}
		
		if($page>1){
			$rs['show']="<li><a href='{$pageFor}1{$get_param}' title='First Page'>&laquo; 首页</a></li>
		  <li><a href='{$pageFor}".($page-1)."{$get_param}' title='Previous Page'>&laquo; 上一页</a></li>";	
		}
		$offset = $pagesize*($page-1);
		$init = 1;
		$max = $totalPage;
		$pagelen=9;
		$pagelen = ($pagelen%2)?$pagelen:$pagelen+1;
		$pageoffset = ($pagelen-1)/2;
		if($totalPage>$pagelen){
			if($page<=$pageoffset){
				$init=1;
				$max = $pagelen;
			}else{
				if($page+$pageoffset>=$totalPage+1){
					$init = $totalPage-$pagelen+1;
				}else{
					$init = $page-$pageoffset;
					$max = $page+$pageoffset;
				}
			}
		}
		//生成html
		for($i=$init;$i<=$max;$i++){
			$current=$i==$page?'current':'';
			$rs['show'].="
				<li><a href='{$pageFor}{$i}{$get_param}' class='number {$current}' title='{$i}'>{$i}</a></li>
			";
		}
		if($page<$totalPage){
			$rs['show'].="<li><a href='{$pageFor}".($page+1)."{$get_param}' title='Next Page'>下一页 &raquo;</a></li>
				  <li><a href='{$pageFor}{$totalPage}{$get_param}' title='Last Page'>尾页 &raquo;</a></li>
			";
		}
		return $rs;
	}
	
}

?>